Lift up workspace rlibs while building
authorAlex Crichton <alex@alexcrichton.com>
Fri, 30 Dec 2016 18:50:39 +0000 (10:50 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 5 Jan 2017 17:34:22 +0000 (09:34 -0800)
I think the condition here was slightly off from before, so invert it subtly to
get what we want, lifting up anything in a workspace or binaries otherwise.

Closes #3432

src/cargo/ops/cargo_rustc/context.rs
tests/path.rs

index a5a16b4791d672411cf6cfca1945ef58f6bf9583..471f8ff370e78cbf6550e3e2d46a0c12adec2185 100644 (file)
@@ -224,7 +224,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
 
             map.insert(crate_type.to_string(), Some((prefix.to_string(), suffix.to_string())));
         }
+
         let cfg = if has_cfg {
             Some(try!(lines.map(Cfg::from_str).collect()))
         } else {
@@ -448,7 +448,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
         // we don't want to link it up.
         if src_dir.ends_with("deps") {
             // Don't lift up library dependencies
-            if self.ws.members().find(|&p| p != unit.pkg).is_some() && !unit.target.is_bin() {
+            if self.ws.members().find(|&p| p == unit.pkg).is_none() &&
+               !unit.target.is_bin() {
                 None
             } else {
                 Some((
index ab9d91bc88ee37b4cc059e2ebf7cb796f08e55e0..082003b3bdb8e99997694e61e9a5e9a6228c11b0 100644 (file)
@@ -979,3 +979,34 @@ location searched: [..]
 version required: *
 "));
 }
+
+#[test]
+fn workspace_produces_rlib() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "top"
+            version = "0.5.0"
+            authors = []
+
+            [workspace]
+
+            [dependencies]
+            foo = { path = "foo" }
+        "#)
+        .file("src/lib.rs", "")
+        .file("foo/Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.5.0"
+            authors = []
+        "#)
+        .file("foo/src/lib.rs", "");
+    p.build();
+
+    assert_that(p.cargo("build"), execs().with_status(0));
+
+    assert_that(&p.root().join("target/debug/libtop.rlib"), existing_file());
+    assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());
+
+}